package com.hanggold.ppt;

import com.aspose.slides.License;
import com.aspose.slides.PdfOptions;
import com.aspose.slides.Presentation;
import com.aspose.slides.SaveFormat;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStream;

/**
 * @author <a href="mailto:sunmch@163.com">smc</a>
 * @date 2019-09-18 17:40
 * @since 1.0.0
 **/
public class PPT2Pdf {

    public static void main(String[] args) throws Exception {
        long start = System.currentTimeMillis();
        InputStream license = PPT2ImageDemo.class.getClassLoader().getResourceAsStream("license.xml");
        if (license != null) {
            License aposeLic = new License();
            aposeLic.setLicense(license);
        }

        FileInputStream fileInput = new FileInputStream("H:" + File.separator + "ljj.pptx");
        Presentation pres = new Presentation(fileInput);

        PdfOptions pdfOptions=new PdfOptions();
        pdfOptions.setJpegQuality((byte)100);
        pdfOptions.setSaveMetafilesAsPng(true);
        pdfOptions.setTextCompression(0);
        pdfOptions.setCompliance(15);
        FileOutputStream out = new FileOutputStream(new File("H:" + File.separator + "33333.pdf"));
        pres.save(out, SaveFormat.Pdf,pdfOptions);
        pres.save(out, SaveFormat.Pdf);
        out.close();
        System.out.println("success");

        long end = System.currentTimeMillis();

        System.out.printf("转换pdf花费时间 :  %d \n", (end - start));

    }
}
